<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
</head>
<body>
<div id="app">
    <input ref="btn" type="button" value="获取元素" @click="getElement">
    <h3 ref="myh3">哈哈 今天天气太好了</h3>
    <hr>
    <login ref="mylogin"></login>
</div>
<script>
    var login={
        template:'<h1>登录组件</h1>',
        data(){
            return{
                msg:'data'
            }
        },
        methods:{
            show(){
                console.log('son')
            }
        }
    }

    var vm=new Vue({
        el:'#app',
        data:{

        },
        methods:{
            getElement(){
                console.log(vm.$refs.myh3)
                console.log(vm.$refs.myh3.innerText)
                console.log(this.$refs.mylogin.msg)
                this.$refs.mylogin.show()
            }
        },
        components:{
            login
        }
    })
</script>
</body>
</html>